//
//  NewsVideoHeader.m
//  Fireball
//
//  Created by 俞渊华 on 2017/12/14.
//  Copyright © 2017年 俞渊华. All rights reserved.
//

#import "NewsVideoHeader.h"
#import "NewsUserView.h"
#import "NewsShareView.h"

@interface NewsVideoHeader ()
/// 作者视图
@property(nonatomic, strong)NewsUserView *userView;
/// 标题
@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)NewsShareView *shareView;
@end

@implementation NewsVideoHeader

-(instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
 
        self.userView = [[NewsUserView alloc]init];
        [self addSubview:self.userView];
        
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.textColor = [UIColor xm_jetblackColor];
        self.titleLabel.font = [UIFont xm_medium:22.0];
        [self addSubview:self.titleLabel];
        
        
        self.shareView = [[NewsShareView alloc] init];
        [self addSubview:self.shareView];
        
        
    }
    return self;
}
-(void)setDetailModel:(AticleDetailModel *)detailModel{
    _detailModel = detailModel;
    self.userView.detailModel = _detailModel;
    self.titleLabel.text =_detailModel.Title;

}





-(void)layoutSubviews{
    [super layoutSubviews];

    [self.userView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(20);
        make.right.mas_equalTo(self).offset(-20);
        make.top.mas_equalTo(self).offset(10);
        make.height.mas_equalTo(@40);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(20);
        make.right.mas_equalTo(self).offset(-20);
        make.top.mas_equalTo(self.userView.mas_bottom).offset(20);
    }];
    
    [self.shareView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(20);
        make.height.mas_equalTo(@120);
    }];
    if (self.heightBlock) {
        self.heightBlock(CGRectGetMaxY(self.shareView.frame) + 20);
    }
}
-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];
}

-(void)dealloc{
//    if (self.model.ViewType == 4) {
//        
//    }
    NSLog(@"dealloc");
}



@end
